<?php
/*
	本插件：$this->model('model')->方法名();
	其他地方调用：model('jy_xiu/model')->方法名();
*/
namespace jy_xiu;
defined('BY_JYA') or exit('error');
class model extends \plugin{
	public function xiu_request($url,$params=array()){
		$cloud=core_setting('cloud');
		if (empty($cloud['plugins']['jy_xiu']['secret'])) {
			$plugin=cloud_request('cloud.secret',array('plugin'=>'jy_xiu'));
			$itemcloud=array_fields(array('cloudkey','secret','url'),$cloud);
			$strarray=array(
				'uid'=>$_SESSION['uniacid'],
				'key'=>$itemcloud['cloudkey'],
				'time'=>TIMESTAMP,
			);
			$str='';
			ksort($strarray);
			foreach($strarray as $key=>$value){
				$str.=$key.$value;
			}
			$str.=$plugin['secret'];
			$sign=md5($str);
			$cloud['plugins']['jy_xiu']=$plugin;
			if ($secret['secret']) {
				core_setting('cloud',$cloud);
			}
		}
		$domain = 'xiu.jinyunweb.com';
		//获取独立域名
		$jy_xiu=core_setting('jy_xiu');
		if($cloud['group'] && $jy_xiu['domain']){
			$domain = $jy_xiu['domain'];
			$name = $jy_xiu['name'];
			$user_appid = $jy_xiu['user_appid'];
			$user_appsecret = $jy_xiu['user_appsecret'];
		}
		$linkurl= HTTP.$domain.'/index.php';
		$query  ='uid='.$_SESSION['uniacid'];
		$query .='&key='.$itemcloud['cloudkey'];
		$query .='&time='.TIMESTAMP;
		$query .='&sign='.$sign;
		$query .='&host='.$_SERVER['HTTP_HOST'];
		$query .='&name='.$name;
		$query .='&user_appid='.$user_appid;
		$query .='&user_appsecret='.$user_appsecret;
		$getlisturl=$linkurl.$url.$query;
		$res=cfc('http')->ihttp_request($getlisturl,$params);
		$list=json_decode($res['content'],true);
		$return['list']=$list;
		$return['query']=$query;
		return $return;
	}
}
?>